import request from "@/utils/request";

/**
 * 用户登录
 * @param {Object} data 登录信息 {username, password}
 * @returns {Promise}
 */
export function login(data) {
  return request({
    url: "/auth/login",
    method: "post",
    data,
  });
}

/**
 * 用户注册
 * @param {Object} data 注册信息 {username, password, nickname}
 * @returns {Promise}
 */
export function register(data) {
  return request({
    url: "/auth/register",
    method: "post",
    data,
  });
}

/**
 * 退出登录
 * @returns {Promise}
 */
export function logout() {
  return request({
    url: "/auth/logout",
    method: "post",
  });
}

/**
 * 刷新 token
 * @returns {Promise}
 */
export function refresh() {
  return request({
    url: "/auth/refreshToken",
    method: "post",
  });
}
